<!DOCTYPE HTML>
<html style="background: #f3f3f3;" lang="zh-cmn-Hans">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>

    <link rel="stylesheet" type="text/css" href="../css/mobiscroll_002.css" >
    <script src="../script/mobiscroll_002.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_004.js" type="text/javascript"></script>
    <script src="../script/mobiscroll.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_003.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_005.js" type="text/javascript"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>邀请统计</h2>
      <!--<a href="javascript:void (0);" class="search_btn set_btn">设置</a>-->
  </header>
</div>
<section class="info_kinds" style="display: none">
    <div class="info">
        <ul>
            <li class=""><a href="javascript:;" onclick="aaplay('personal_distribution_profit')">收益统计</a></li>
            <li class="active"><a href="javascript:;" onclick="aaplay('personal_distribution_invite')">邀请统计</a></li>
        </ul>
    </div>
</section>
<div id="con">
<!-- <section class="statistics">
    <div class="statistics_time">
        <div class="time">
            <p>累计邀请</p>
            <span>0人</span>
        </div>
        <a href="javascript:void (0);" class="date_btn"><img src="../image/date_icon.png" alt=""></a>
    </div>
    <div class="user_info">
        <ul>
            <li>
                <a href="javascript:;">
                    <img src="../image/infoImg1.png" alt="">
                    <div class="info">
                        <p>138****8868</p>
                        <span>2017-6-1 09:35</span>
                    </div>
                    <div class="status">
                        <span>注册成功</span>
                    </div>
                </a>
            </li>


        </ul>
    </div>
</section>
<section class="statistics">
    <div class="statistics_time">
        <div class="time">
            <p>累计邀请</p>
            <span>15人</span>
        </div>
    </div>
    <div class="user_info">
        <ul>
            <li>
                <a href="javascript:;">
                    <img src="../image/infoImg1.png" alt="">
                    <div class="info">
                        <p>138****8868</p>
                        <span>2017-6-1 09:35</span>
                    </div>
                    <div class="status">
                        <span>注册成功</span>
                    </div>
                </a>
            </li>


        </ul>
    </div>
</section> -->
</div>

</body>

<script>
    var date='';
    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        
        api. addEventListener({name:'scrolltobottom'}, function(ret, err){

            //toDoRequest();

        });


        toDoRequest()
    };



    function toDoRequest(){
        var p= {token:token,date:date};
        api.ajax({
            url: webSiteUrl+'/app/user/yaoqin',
            method: 'post',
            data: {
                values:p
            }
        }, function(ret, err) {

            if(ret.code==200){

                var html = "";
                var t=ret.data;


                var tj=ret.data;
                console.log(tj);
                console.log(ret.msg);
                if(tj != null){
                    if(date == ''){

                        for(var i=0;i<tj.length;i++){

                            html+='<section class="statistics"><div class="statistics_time"><div class="time"><p>累计邀请</p><span>'+tj[i].num+'人</span></div>';
                            if(i==0){
                                html+='<a href="javascript:void (0);" class="date_btn"  id="date1"><img src="../image/date_icon.png"><input onchange="datechoose()" readonly="readonly" name="appDateTime"  id="appDate" type="text"  class="hideinput"></a>';
                            }
                            html+='</div><div class="user_info"><ul>';

                            var tjm=tj[i].month;

                            if(tjm.length>0){
                                for(var j=0;j<tjm.length;j++) {
                                    html += '<li><a href="javascript:;"><img src="'+webSiteUrl+tjm[j].icon+'" alt=""><div class="info"><p>'+tjm[j].phone+'</p><span>'+tjm[j].time+'</span></div><div class="status"><span>注册成功</span></div></a></li>';
                                }
                            }

                            html+='</ul></div></section>';

                        }

                        $('#con').html(html);
                        $("#appDate").mobiscroll($.extend(opt['date'], opt['default']));

                    }else{


                        html+='<section class="statistics"><div class="statistics_time"><div class="time"><p>累计邀请</p><span>'+tj.num+'人</span></div>';

                        html+='<a href="javascript:void (0);" class="date_btn"  id="date1"><img src="../image/date_icon.png"><input onchange="datechoose()" readonly="readonly" name="appDateTime"  id="appDate" type="text"  class="hideinput"></a>';

                        html+='</div><div class="user_info"><ul>';

                        var tjm=tj.month;
                        if(tjm!=null){
                            for(var j=0;j<tjm.length;j++) {
                                html += '<li><a href="javascript:;"><img src="'+webSiteUrl+tjm[j].icon+'" alt=""><div class="info"><p>'+tjm[j].phone+'</p><span>'+tjm[j].time+'</span></div><div class="status"><span>注册成功</span></div></a></li>';
                            }
                        }


                        html+='</ul></div></section>';
                    }
                    $('#con').html(html);
                    $("#appDate").mobiscroll($.extend(opt['date'], opt['default']));

                }else{
                    $('#con').html('<p style="text-align:center">暂无数据</p>');
                }
                //alert(tj.length);

            }else{

                $('#con').html('<p style="text-align:center">暂无数据</p>');


            }
        });

    }

    //时间选择
    var currYear = (new Date()).getFullYear();
    var opt={};
    opt.date = {preset : 'date'};
    opt.datetime = {preset : 'datetime'};
    opt.time = {preset : 'time'};
    opt.default = {
        theme: 'android-ics light', //皮肤样式
        display: 'modal', //显示方式
        mode: 'scroller', //日期选择模式
        dateFormat: 'yyyy-mm',
        lang: 'zh',
        showNow: false,
        nowText: "今天",
        startYear: currYear , //开始年份
        endYear: currYear + 10 //结束年份
    };


    function datechoose(){
        date=$('#appDate').val()
        toDoRequest()
    }

    /*var div = $("#date1").html();

    setInterval(function() {return;
        var divNew = $("#date1").html();
        if(div != divNew) {
            div=divNew
            date=divNew
            console.log(date)
            toDoRequest2()
        }
    }, 100);



    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date1',
            type: 'month'
        });
    })*/

</script>
</html>
